#ifndef DRAWDIAGRAM_H
#define DRAWDIAGRAM_H

#include <QObject>
#include <QWidget>

struct draw_pixel
{
    union {
        uint32_t pixel;
        struct { int16_t y; int16_t x; };
    };
};
struct matrix_pixel
{
    union
    {
#if 1
        uint16_t pixel;
        struct
        {
#if 0
            int8_t x;
            int8_t y;
#endif
            uint16_t angle: 9;
            uint16_t radius:7;
        };
#else
        uint32_t pixel;
        struct
        {
#if 0
            int8_t x;
            int8_t y;
#endif
            double angle;
            double radius;
        };
#endif
    };
};
#define   MATRIX_SIZE    41

// 绘制矢量图
class DrawDiagram : public QObject
{
    Q_OBJECT
public:
    explicit DrawDiagram(QWidget* const widget, QObject *parent = nullptr);

    void get_draw_square_map(void);
    void gridding(uint16_t row, uint16_t col);
    void square1(const int _wh, uint16_t divide);
    void square2(uint16_t num, uint16_t divide);
    void square3(uint16_t num, uint16_t divide);
    void circle(uint16_t num, uint16_t divide);
    void square(uint16_t num);
    // 画等分圆
    void divide_circle(const uint16_t Divide);
    void divide_arc(const uint16_t Divide);
signals:


private:
    QWidget* const Widget;
    int16_t bar_len;
    uint32_t bar[128];
    uint16_t Bar_Cnt;
    struct matrix_pixel matrix[MATRIX_SIZE][MATRIX_SIZE];
};

#endif // DRAWDIAGRAM_H
